/**
 * 
 */
package algo3c2g15.vista;

import javax.swing.JDialog;

import algo3c2g15.domain.Region;

/**
 * @author De La
 *
 */
public class VentanaRegion extends JDialog {
	private static final long serialVersionUID = 1L;
	
	private static VentanaRegion instance = null;
	private static PanelConsUnidad panel;
	
	private VentanaRegion( Region region ) {
		super();
		setTitle(region.getNombre());
		setBounds(400, 100, 300, 400);
		setResizable(false);
		setAlwaysOnTop(true);
		
		panel = new PanelConsUnidad( region );
		add(panel);
		
		setVisible(true);
	}
	
	public static VentanaRegion getInstance(){
		return instance;
	}
	
	public static void createVentanaRegion(Region region){
		if (instance != null) {
			region.deleteObserver( panel );
			instance.dispose();
		}
		instance = new VentanaRegion( region );
	}
	
	public static void cerrar(){
		if (instance != null) {
			panel.getRegion().deleteObserver( panel );
			instance.dispose();
		}
	}
}
